package com.example.demo.Mapper;

import com.example.demo.Entity.CampusExperience;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CampusExperienceMapper {
    @Select("SELECT * FROM campus_experience WHERE person_id = #{userId}")
    List<CampusExperience> findByUserId(Long userId);

    // 批量更新校园经历
    void batchUpdateCampusExperiences(@Param("experiences") List<CampusExperience> experiences);

    // 删除指定用户的所有校园经历
    @Delete("DELETE FROM campus_experience WHERE person_id = #{userId}")
    int deleteByUserId(Long userId);

    // 删除单个校园经历
    @Delete("DELETE FROM campus_experience WHERE id = #{id}")
    int deleteById(Long id);

    // 插入校园经历
    @Insert("INSERT INTO campus_experience(person_id, organization, position, start_date, end_date, description) " +
            "VALUES(#{person_id}, #{organization}, #{position}, #{start_date}, #{end_date}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(CampusExperience experience);
}
